package eng.geom;

import java.awt.Point;

public class GeometricTransformations {

	/**
	 * @param xstart
	 * @param ystart
	 * @param xend
	 * @param yend
	 * @param rodLength
	 * @return
	 */
	public static double angleFull(int xstart, int ystart, int xend, int yend,
			double rodLength) {
		double angle ;		
		if(xend != xstart)
		{
			angle=-Math.atan2(yend-ystart, xend-xstart);
		} else
		{
			angle = -Math.PI/2;
			if(yend<ystart)
			{
				angle = -angle;
			}
		}
		return angle;
	}
	
	/** 
	 * rotation of point around another point by a certain amount of degrees
	 * @param pt :  point to be rotated
	 * @param center  : pivot point
	 * @param angleDeg : degrees
	 * @return pt
	 */
	public static Point rotatePoint(Point pt, Point center, double angleRad)
	{
		double cosAngle = Math.cos( angleRad);
		double sinAngle = Math.sin(-angleRad);
		int dx=(pt.x-center.x);
		int dy=(pt.y-center.y);
		pt.x = center.x + (int) (dx*cosAngle - dy*sinAngle);
		pt.y = center.y + (int) (dx*sinAngle + dy*cosAngle);
		return pt;
	}
}
